#include <pthread.h>
#include <functional>
#include <string>
#include <cstdio>

class ThreadData
{
public:
    std::string _name;
    void* _args;
};

//typedef std::function<void*(void*)> fun_t;
typedef void*(*fun_t)(void*);
class Thread
{
public:
    Thread(int num,fun_t func,void* args):_func(func)
    {
        char nameBuffer[64];
        snprintf(nameBuffer,sizeof(nameBuffer),"Thread-%d",num);
        _name = nameBuffer;

        _data._args = args;
        _data._name = _name;
    }
    void start()
    {
        pthread_create(&_tid,nullptr,_func,(void*)&_data);
    }
    void join()
    {
        pthread_join(_tid,nullptr);
    }
    std::string getName()
    {
        return _name;
    }
    ~Thread()
    {}

private:
    std::string _name;
    fun_t _func;
    ThreadData _data;  //线程数据
    pthread_t _tid;
};